package com.haojii.notifier.observer;

import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;

import com.haojii.notifier.Entity;
import com.haojii.notifier.Notifiable;
import com.haojii.notifier.helper.SMSSender;
import com.haojii.notifier.user.User;

/**
 * 
 * 
 * @author hao
 *
 */
public class SMSNotifier extends Notifiable implements Observer {

	private static final Logger log = Logger.getLogger(SMSNotifier.class.getName());
	
	public void update(Observable o, Object arg) {
		for (User user : this.getNotifierList()) {
			log.info("SMS "+user.getEmail() +" : "+ ((Entity)arg).smsMessage());
			SMSSender.send(user.getCellphone(), ((Entity)arg).smsMessage());
		} 
	}

}
